from django.db import models
from django.contrib import admin
from django.utils.translation import ugettext_lazy as _

class Host(models.Model):
    name = models.CharField(max_length=100)
    address = models.CharField(max_length=15)
    desc = models.TextField()

    def __unicode__(self):
        return "%s (%s)"%(self.address, self.name)

    class Meta:
        verbose_name = _('host')
        verbose_name_plural = _('hosts')

class PingResponse(models.Model):
    # Data returned by the test
    response_time = models.FloatField(default=-1)
    time = models.DateField(auto_now=True)

    host = models.ForeignKey(Host)

    def __unicode__(self):
        return "%s (Response time: %f, timestamp: %s )"%(self.host.address, self.response_time, self.time)

class CronTab(models.Model):
    CHOICES = (
        ('*', 'Todos'),
        ) + tuple(map(lambda x: ("%02d"%x,"%02d"%x), range(60)))
    Minute = models.CharField(choices=CHOICES, max_length=2)
    Hour = models.CharField(choices=CHOICES, max_length=2)


# Create your models here.

#admin.site.register((Host, CronTab, PingResponse))
